package com.lizhongbao.cloud.biz.service;

import com.alibaba.fastjson.JSONObject;
import com.lizhongbao.cloud.biz.domain.dto.TestDto;
import com.lizhongbao.cloud.biz.domain.dto.TestQueryDto;
import com.lizhongbao.cloud.biz.domain.eo.Test;
import com.lizhongbao.cloud.biz.extension.RequestContext;
import com.lizhongbao.cloud.biz.provider.BizProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * 测试 Service
 * @Author lizhongbao
 * @Date 2019/12/24 11:16
 **/
@Service
public class BizService {

    private static Logger logger = LoggerFactory.getLogger(BizProvider.class);

    public JSONObject page(TestQueryDto dto, Long page, Long size) {
        JSONObject json = new JSONObject();
        json.put("dto", dto);
        json.put("page", page);
        json.put("size", size);
        json.put("context", RequestContext.getXUser());
        return json;
    }

    public JSONObject list(TestQueryDto dto) {
        JSONObject json = new JSONObject();
        json.put("dto", dto);
        return json;
    }

    public Test detail(Long id) {
        Test test = new Test();
        test.setId(id);
        test.setName("test");
        return test;
    }

    public Boolean create(TestDto dto) {
        logger.info("create：" + dto.toString());
        logger.info("context：" + RequestContext.getXUser());
        return true;
    }

    public Boolean update(Long id, TestDto dto) {
        logger.info("update：" + id);
        logger.info("update：" + dto.toString());
        return true;
    }

    public Boolean delete(Long id) {
        logger.info("delete：" + id);
        return true;
    }

    public Boolean delete(Long[] ids) {
        for (Long id : ids) {
            logger.info("delete：" + id);
        }
        return true;
    }

}
